<script language="javascript">
var notAllow = " {$f} ";
</script>
<style type="text/css">
<!--
.nw { float:left; width:150px; }
.cls { clear:both; }
-->
</style>
<form name="form1">
    <!-- 基本属性 -->
    <div class="Item hr">
        <div class="current">修改字段字段</div>
        <div class="fr"><a class="btn" href="{:U('edit', array('id' => $id))}">返回当前表单</a></div>
        <div class="fr"><a class="btn" href="{:U('index')}">自定义表单管理</a></div>
    </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
    <tbody>
    <tr> 
      <th>表单提示文字：</th>
      <td>
      	<input type="text" class="input" id="field_label" name="field[comment]" value="{$comment}" /> * <span onclick="ShowHide('help_field_label')" class="icon-question-sign hand" title="帮助"></span> <span id="help_field_label">（发布内容时显示的提示文字）</span></td>
    </tr>
    <tr> 
      <th width="100">字段名称：
      </th>
      <td>{$name}</td>
    </tr>
    <tr> 
      <th>数据类型：</th>
      <td>
      	<select name="field[type]" id="type" style="width:200px">
        <volist name='fieldtype' id='typetext'>
              <option value="{$key}" <if condition='$key eq $type'> selected</if>>{$typetext}</option>
		</volist>
        </select>        
       </td>
    </tr>
    <tr> 
      <th>默认值：</th>
      <td> 
      	<textarea  class="jq_watermark" rows="5" cols="100" id="vdefault" name="field[value]" placeholder='如果定义数据类型为select、radio、checkbox时，此处填写被选择的项目(用","分开，如"男,女,人妖")。'>{$value}</textarea>
      </td>
    </tr>
    <tr> 
      <th>最大长度：
      </th>
      <td>
      	<input type="text" style="width:80px;" class="input" id="maxlength" name="field[length]" value="{$length}"> <span onclick="ShowHide('help_maxlength')" class="icon-question-sign hand" title="帮助"></span> <span id="help_maxlength">（文本数据必须填写，大于255为text类型）</span>
       </td>
    </tr>
</tbody></table>
    <input type="hidden" name="id" value="{$id}" />
    <input type="hidden" name="field[name]" value="{$name}" />
    <input type="hidden" name="act" value="edit" />
</form>
<div class="commonBtnArea" >
    <button class="btn submit">提交</button>
</div>

<script type="text/javascript">
$(function(){
    submitForm("doField");
});
function submitForm(action) {
    $(".submit").click(function(){
		var theform = document.form1;
		var itemname = $("#field_label").val();
		var dtype = 'text';
		var enums = document.getElementsByName('field[type]');
		for(i=0;i<enums.length;i++)
		{
			if(enums[i].checked) dtype = enums[i].value;
		}
		var vdefault = $("#vdefault").value;
		var maxlength = $("#maxlength").value;
		
		if(itemname=="")
		{
			popup.error("表单提示名称不能为空！");
			setTimeout(function(){
				popup.close("asyncbox_success");
			},2000);
			return false;
		}
		
		if((dtype=="radio" || dtype=="select" || dtype=="checkbox") && vdefault=="")
		{
			popup.error("你选择的select或radio、checkbox类型，必须默认值设置选择的项目（用逗号[,]分开）！");
			setTimeout(function(){
				popup.close("asyncbox_success");
			},2000);
			return false;
		}
        commonAjaxSubmit("__URL__/" + action);
        return false;
    });
}
</script>